package com.abcd.thread.base;

/**
 * @program: java-base
 * @description: 锁的对象
 * @author: Liu
 **/
public class LockObject implements Runnable{

    private static final Integer abc = 1;

    public static synchronized void point() {
        synchronized (abc) {
            for (int i = 0; i < 100; i++) {
                System.out.println("1");
            }        }
    }

    public static void pointElse() {
        synchronized (abc) {
            for (int i = 0; i < 100; i++) {
                System.out.println("2");
            }
        }
    }

    /**
     * TODO 因该是两个对象同时请求这两个方法，看打印结果是交叉的还是顺序的，来判断synchronized锁对象是一个静态常量的作用
     */
    @Override
    public void run() {
        point();
        pointElse();
    }
}